package com.example.xadmin.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.xadmin.common.Result;
import com.example.xadmin.dao.SysPermissionMapper;
import com.example.xadmin.pojo.SysPermission;
import com.example.xadmin.service.SysPermissionService;
import com.example.xadmin.util.TreeUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2020-04-05
 */
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements SysPermissionService {


    @Override
    public Result<JSONArray> listAllPermission() {
        List<SysPermission> res = this.list();
        JSONArray jsonArray = new JSONArray();
        TreeUtil.tree(0,res,jsonArray);
        return Result.ok(0,jsonArray);
    }
}
